<?php
/**
 * 首页相关操作
 * @author sz 2016-8-31 15:16:58
 * @version 1.0
 */
namespace Home\Controller;
class IndexController extends PmpController
{

    /**
     * 默认首页
     *
     * @author sz 2016-8-31 09:49:12
     * @version 1.0
     */
    public function index ()
    {
        $user_name = $_SESSION['hb_think_name'];
        if ($user_name != null)
        {
            
            
            $this->display();
        }
        else
        {
             header("Location: " . '?c=login&a=index');
        }
    }
    
    /**
     * 修改密码
     * 2016-9-28 14:03:27
     * sz
     */
    public function changePwd ()
    {
        $user_id = $_SESSION['hb_think_id'];
        $old_password = $_POST['old_password'];
        $new_password = $_POST['new_password'];
       
        $memberUserModel = D('MemberUser');
        $memberArray = $memberUserModel->getUserById($user_id);
        if($memberArray != null)
        {
        	$salt = $memberArray[0]['salt'];
        	$old_password = md5(md5($old_password) . $salt);
        	if($old_password != $memberArray[0]['password'])
        	{
        		echo "-9";
        	}
        	else 
        	{
        	    $salt = $this->getCharAndNumr(6);
        	    $new_password = md5(md5($new_password) . $salt);
        	    $modifyFlag = $memberUserModel->modifyPwd($user_id, $new_password, $salt);
        	    if ($modifyFlag >= 0)
        	    {
        	        $logArray[$this->operationMod][] = "【账号管理】->【修改密码】";
        	        $this->addLog($logArray);
        	        echo "1";
        	    }
        	    else 
        	    {
        	    	echo "0";
        	    }
        	}
        }
    }

    /**
     * 注销
     *
     * @author sz 2016-6-15 09:27:24
     * @version 1.0
     */
    function logout ()
    {
        session(null);
        header("Location: " . '?c=login&a=index');
    }
}